#ifdef MEM_DEBUG
#include <map>
#include "Singleton.h"
#include <ostream>
#include <string>

#ifndef MEMORY_H_INCLUDED
#define MEMORY_H_INCLUDED

struct Allocation
{
	Allocation();
	Allocation(void* m_Addr, size_t m_Size, int Number, std::string Name);

	void* m_Addr;
	size_t m_Size;
	int m_LineNumber;
	std::string m_FileName;
};

inline std::ostream& operator<<(std::ostream& os, const Allocation& alloc)
{
	static int count = 0;
	count++;

	return os << "Object " << count <<  "\nAddr: " << alloc.m_Addr << " Size: " << alloc.m_Size 
				<< "\nAdded To Heap In: " << alloc.m_FileName << "\nLine Number: " << alloc.m_LineNumber << "\n\n";
}

class AllocationManager : public Uncopyable
{
public:
	~AllocationManager();
	void CreateAllocation(Allocation);
	void RemoveAllocation(void* a);
	int MemoryUseage(bool New, size_t size);
	size_t ReturnSize(void* a);
	void Print();
	private:
	AllocationManager() {}
	friend class Singleton<AllocationManager>;
	std::map<void*, Allocation> TheAllocMap;
};

typedef Singleton<AllocationManager> TheAllocationManager;

void* operator new(size_t size, int LineNumer, std::string FileName);
void operator delete(void* p);
#define new new(__LINE__, __FILE__)


#endif

#endif
